package com.mspbots.core.wise.controller;

import com.mspbots.core.AbstractBaseController;
import com.mspbots.core.wise.controller.params.UserMappingParams;
import com.mspbots.core.wise.model.TenantUserMapping;
import com.mspbots.core.wise.service.TenantUserMappingService;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.Callable;

/**
 * @author billb
 */
@RestController
@RequestMapping("user-mapping")
public class TenantUsersMappingController extends AbstractBaseController<TenantUserMapping, TenantUserMappingService> {

    @GetMapping(path = "/user")
    public Callable selectByTenantUserId(UserMappingParams params) {
        return () -> this.service.findByOne(params);
    }


    @PostMapping(path = "/save")
    public Callable saveOrUpdate(@RequestBody TenantUserMapping dto) {
        return () -> {
            service.saveOrUpdate(dto);
            return dto;
        };
    }

    @GetMapping(path = "/detail")
    public Callable detail(UserMappingParams params) {
        return () -> this.service.detail(params);
    }

    @GetMapping(path = "/command-detail")
    public Callable commandDetail(UserMappingParams params) {
        return () -> this.service.commandDetail(params);
    }


}
